const { Schema } = require('./config')
// 声明mogoose的特殊数据类型objectId
const objectId = Schema.Types.ObjectId

const articleSchema = new Schema({
  title: String,
  content: String,
  tips: String,
  author: {
    type: objectId,
    ref: "users"  // 把article和users表关联起来
  },
  commentNum: Number
}, {
  timestamps: {
    // 配置文章创建时间
    createdAt: "created"
  }
})

module.exports = articleSchema